<?php
/**
 * cms后台新闻添加管理页
 * author wang
 */

define("PHP_IN",true);
require "../include/init.php";
require "checklogin.php";
require ROOT_PATH."cms/smart_connection.php";

if(isset($_POST['dosubmit'])){
    $title = $_POST['title'];
    $intro = $_POST['intro'];
    $isdisplay = intval($_POST['isdisplay']);
    $content = isset($_POST['editorValue']) ? $_POST['editorValue'] : "";
    $addtime = time();
    if($title=="" || $intro=="" || $content==""){
        alert("请填写完整的文章内容");
        exit;
    }
    $sql = "INSERT INTO news (title,intro,content,addtime,isdisplay) VALUES
    ('$title','$intro','$content','$addtime','$isdisplay')";
    $result = $db->query($sql);
    if($result){
        alert("添加成功","news_list.php");
    }else{
        alert("添加失败");
    }
}

$smarty->display("news_add.tpl");
$db->close();
?>
